/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import data.Jobrotation;
import java.util.List;
import util.BaseDAO;

/**
 *
 * @author Hùng
 */
public class JobrotationDAO extends BaseDAO {

    public JobrotationDAO() {
    }

    public List<Jobrotation> getalljobrotation() {
        String hql = "from Jobrotation";
        List<Jobrotation> lJob = executeHQLQuery(hql);
        return lJob;
    }

    public List<Jobrotation> getAllJobRotationofE(String idE) {
        String hql = "from Jobrotation s where s.employees = '"+ idE+"'";
        List<Jobrotation> lJob = executeHQLQuery(hql);
        if(lJob.isEmpty()){
            return null;
        }
        return lJob;
    }
    public Jobrotation getJobrotationByIdJob(int idJob){
        String hql = "from Jobrotation s where s.id = " + idJob;
        List<Jobrotation> tmpJob = executeHQLQuery(hql);
        if(tmpJob == null){
            return null;
            
        }
        return tmpJob.get(0);
    }

    public List<Jobrotation> getJobrorationbyIdDesign(String idDesign) {
        String hql = "from Jobrotation s where s.designation = '" + idDesign+"'";
         List<Jobrotation> lJob = executeHQLQuery(hql);
         if(lJob != null ){
             return lJob;
         }
        return null;
    }
}
